server {
    listen 80;
    server_name your-domain.com;  # 替换为您的域名或服务器IP

    # 日志文件路径
    access_log /var/log/nginx/vue-app-access.log;
    error_log /var/log/nginx/vue-app-error.log;

    # 应用程序根目录
    root /path/to/dist;  # 替换为您服务器上dist目录的实际路径
    index index.html;

    # gzip压缩配置
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
    gzip_vary on;

    # 缓存静态资源
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
        expires 1y;
        add_header Cache-Control "public, max-age=31536000";
        access_log off;
    }

    # 所有路由都返回index.html
    location / {
        try_files $uri $uri/ /index.html;
    }

    # 禁止访问.htaccess文件
    location ~ /\.ht {
        deny all;
    }
} 